from django.http import HttpResponse, Http404
from django.db.models import get_model
from manager import DefaultSearch

__all__ = ["description"]

def description(request, app_label, model_name):
	model = get_model(app_label, model_name)
	if not model:
		raise Http404("No such model")
	search = DefaultSearch(model)
	if not search:
		raise Http404("No search")

	response = HttpResponse()
	response["Content-Type"] = "application/opensearchdescription+xml"

	response.write(search.description)

	return response
	
